Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Scripting Additions Guide /
Chapter 2 - Scripting Addition Commands / Command Definitions
/


Round

The Round command rounds or truncates a number to an integer. It is one of two commands provided by the Numerics scripting addition.

By default, Round rounds to the nearest number. You may also include an optional parameter to specify rounding up, down, toward zero, or to the nearest number.

SYNTAX
round number ¬
   [ rounding ( up | down | toward zero | to nearest ) ]
PARAMETER
number
The number to round.
Class: Number
See the examples that follow for demonstrations of the possible values of the rounding parameter.

RESULT
The result is an integer: the rounded value.

EXAMPLES
display dialog "round -3.67: " & (round -3.67) & return & ¬
   "round 3.67: " & (round 3.67)
display dialog "round -3.67 up: " &  ¬
   (round -3.67 rounding up) & return & ¬
   "round 3.67 up: " & (round 3.67 rounding up)
display dialog "round -3.67 down: " & ¬
   (round -3.67 rounding down) & return & ¬
   "round 3.67 down: " & (round 3.6 rounding down)
display dialog "round -3.67 toward zero: " & ¬
   (round -3.67 rounding toward zero) & return & ¬
   "round 3.67 toward zero: " & ¬
   (round 3.67 rounding toward zero)
display dialog "round -3.67 to nearest: " & ¬
   (round -3.67 rounding to nearest) & return & ¬
   "round 3.67 to nearest: " & ¬
   (round 3.67 rounding to nearest) 
ERRORS
Error
number
Error message
-50Parameter error.
-108Out of memory.
-1700Can't make some data into the expected type.
-1701Some parameter is missing for <commandName>.
-1704Some parameter was invalid.
-1705Operation involving a list item failed.
-1708<reference> doesn't understand the <commandName> message.
-1718Reply has not yet arrived.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
18 DEC 1996